package com.opencloud.ywt.provider.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.opencloud.common.model.PageParams;
import com.opencloud.ywt.client.model.entity.BhyfClass;
import com.opencloud.ywt.provider.mapper.BhyfClassMapper;
import com.opencloud.ywt.provider.service.BhyfClassService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 动量服务
 * @author yeyong
 */

@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class BhyfClassServiceImpl implements BhyfClassService {
    @Autowired
    private BhyfClassMapper bhyfClassMapper;

    @Override
    public IPage<BhyfClass> findListPage(PageParams pageParams) {
        BhyfClass query = pageParams.mapToObject(BhyfClass.class);
        QueryWrapper<BhyfClass> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getGid()), BhyfClass::getGid,query.getGid());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getGradenum()), BhyfClass::getGradenum,query.getGradenum());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getId()), BhyfClass::getId,query.getId());
        queryWrapper.lambda().eq(BhyfClass::getStatus,1);
        queryWrapper.lambda().orderByDesc(BhyfClass::getId);
        return bhyfClassMapper.selectPage(new Page(pageParams.getPage(), pageParams.getLimit()), queryWrapper);
    }
}